package com.chuangshu.chuangshuteam.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chuangshu.chuangshuteam.entity.FileInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FileInfoMapper extends BaseMapper<FileInfo> {

    /**
     * 根据业务ID和业务类型查询文件列表
     * @param businessId 业务ID
     * @param businessType 业务类型
     * @return 文件列表
     */
    @Select("SELECT * FROM file_info WHERE business_id = #{businessId} AND business_type = #{businessType}")
    List<FileInfo> selectByBusinessIdAndType(@Param("businessId") Long businessId, @Param("businessType") String businessType);

    /**
     * 根据业务ID和业务类型删除文件记录
     * @param businessId 业务ID
     * @param businessType 业务类型
     * @return 删除的记录数
     */
    @Delete("DELETE FROM file_info WHERE business_id = #{businessId} AND business_type = #{businessType}")
    int deleteByBusinessIdAndType(@Param("businessId") Long businessId, @Param("businessType") String businessType);
}
